# A bit of 64bit detection.
INCLUDE( CheckTypeSize )
check_type_size( "void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY )

# ###############################################
# Set the compiler SSE options from the selections.
# Detect MSVC or Intel compilers.
# A note about VC's flags.  While enabling the instructions
# for SSE2 to be used by the compiler is possible the
# compiler itself does not use additions from SSE3-4 and
# skips straight to AVX.  This does not mean that the
# intrinsics are in anyway limited by these settings,
# this only applies to optimizations made by the
# compiler itself.
IF( COMPILER_MSVC OR COMPILER_INTEL )
	# Don't add the arch flags for 64bit compiles, they are
	# guaranteed and unrecognized except the AVX flag.
	IF( SIMD_SSE_AVX )
		SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX" )
		SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX" )

	ELSEIF( SIZEOF_VOID_P==4 AND (SIMD_SSE_4 OR SIMD_SSE_3 OR SIMD_SSE_2) )
		SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2" )
		SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2" )

	ELSEIF( SIZEOF_VOID_P==4 AND SIMD_SSE )
		SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE" )
		SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE" )

	ELSEIF( SIZEOF_VOID_P==4 )
		SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:IA32" )
		SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:IA32" )
	ENDIF()

	IF( MSVC_IDE )
		SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries )
		SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries )
		SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries )

		ADD_DEFINITIONS( -D_VARIADIC_MAX=10 )
	ENDIF()

ENDIF()
